-module(misc).
-export([b_not/1]).
-export([b_and/2]).
-export([print_sth/2]).

-export([test_print/0]).
-export([average/1]).
-export([member/2]).

b_not(Bvar) -> 
	if
		Bvar =:= true ->
			false;
		Bvar =:= false ->
			true
	end.
	
b_and(Bvar1, Bvar2) ->
	if
		Bvar1 =:= Bvar2 ->
			Bvar1;
		Bvar1 =/= Bvar2 ->
			0
	end.

test_print() ->
	print_sth("~f", 2).

print_sth(Format, Value) ->
	case Format of
	  "~c" ->
		io:format("print ascii code to character ~c ", [Value]);
	  "~f" -> 
		io:format("print float with 6 decimal places ~f", [Value])

	end.

%% UNSAFE
%% unsafe(X) ->
%% 	case X of
%% 	one -> Y = true;
%% 	_ -> Z = two
%% 	end,
%% Y.

%% Adding 1 to every elements of list

%%calc sum of list

sum([]) -> 0;
sum([Head | Tail]) -> Head + sum(Tail).
average(L) -> sum(L) / length(L).

member([], X) -> false;
member([H | T], X) ->
	if
		H =:= X -> 
			true;
		H =/= X ->
			member(T, X)
	end.









